package com.itfreer.gis.locus.data.entity;

import com.itfreer.form.api.entity.EntityBase;
import com.itfreer.form.api.reflect.DictionaryField;
import com.itfreer.utils.file.FileMeta;
import com.itfreer.utils.json.JsonUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 定义巡护任务实体
 */
@Entity(name = "gis_locus_work")
public class LocusWorkEntity extends EntityBase implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@Id
	@Column(name = "id", length = 50, nullable = true)
	private String id;

	/**
	 * 巡护标题
	 */
	@Column(name = "taskTheme", length = 50, nullable = true)
	private String taskTheme;

	/**
	 * 任务开始时间
	 */
	@Column(name = "start_time", nullable = true)
	private java.util.Date starttime;

	/**
	 * 任务截止时间
	 */
	@Column(name = "ent_time", nullable = true)
	private java.util.Date enttime;

	/**
	 * 巡查周期
	 */
	@Column(name = "cycle", length = 50, nullable = true)
	@DictionaryField(dictionaryName = "dic_xhzq", toFieldName = "cycleName")
	private String cycle;

	@Transient
	private String cycleName;

	/**
	 * 巡查时长
	 */
	@Column(name = "duration", length = 50, nullable = true)
	private String duration;

	/**
	 * 巡查里程
	 */
	@Column(name = "mileage", length = 50, nullable = true)
	private String mileage;

	/**
	 * 巡查单位
	 */
	@Column(name = "s_unit", length = 50, nullable = true)
	@DictionaryField(dictionaryName = "p_administrative", toFieldName = "unitName")
	private String unit;

	@Transient
	private String unitName;

	/**
	 * 巡查人员
	 */
	@Column(name = "ower", length = 50, nullable = true)
	private String ower;

	@Column(name = "owerName", length = 50, nullable = true)
	private String owerName;

	/**
	 * 任务内容
	 */
	@Column(name = "content", length = 50, nullable = true)
	private String content;

	/**
	 * 年份
	 */
	@Column(name = "year", length = 50, nullable = true)
	private String year;

	/**
	 * 巡查次数
	 */
	@Column(name = "s_count", length = 50, nullable = true)
	private String count;

	/**
	 * 备注
	 */
	@Column(name = "remark", length = 50, nullable = true)
	private String remark;

	/**
	 * 附件
	 */
	@Column(name = "image", columnDefinition = "text", nullable = true)
	private String image;


	/**
	 * 巡护状态
	 * */
	@Column(name = "status", length = 50, nullable = true)
	private String status;

	/**
	 * 任务类型
	 * */
	@Column(name = "task_type", length = 50, nullable = true)
	@DictionaryField(dictionaryName = "dic_taskType", toFieldName = "taskTypeName")
	private String taskType;

	@Transient
	private String taskTypeName;

	/**
	 * 创建人ID
	 */
	@Column(name = "s_createUserid", length = 50, nullable = true)
	private String createUserid;

	/**
	 * 创建人
	 */
	@Column(name = "s_createUsername", length = 50, nullable = true)
	private String createUsername;

	/**
	 * 创建时间
	 */
	@Column(name = "s_createTime", nullable = true)
	private java.util.Date createTime;

	/**
	 * 更新人ID
	 */
	@Column(name = "s_updateUserid", length = 50, nullable = true)
	private String updateUserid;

	/**
	 * 更新人
	 */
	@Column(name = "s_updateUsername", length = 50, nullable = true)
	private String updateUsername;

	/**
	 * 更新时间
	 */
	@Column(name = "s_updateTime", nullable = true)
	private java.util.Date updateTime;

	@Transient
	private String nowTime;


	@Transient
	private String secretKey;

	@Transient
	private List<String> handleList;

	@Column(name = "s_zones", nullable = true)
	private String zones;

	public String[] getZones() {
		return this.getStringArray(zones);
	}

	public void setZones(String[] zones) {
		this.zones = this.getArrayString(zones);
	}


	/**
	 * id
	 */
	@Override
	public String getId() {
		return id;
	}

	/**
	 * id
	 */
	@Override
	public void setId(String value) {
		this.id = value;
	}

	/**
	 * 巡护位置
	 */
	public String getTaskTheme() {
		return taskTheme;
	}

	/**
	 * 巡护位置
	 */
	public void setTaskTheme(String value) {
		this.taskTheme = value;
	}

	/**
	 * 任务开始时间
	 */
	public java.util.Date getStarttime() {
		return starttime;
	}

	/**
	 * 任务开始时间
	 */
	public void setStarttime(java.util.Date value) {
		this.starttime = value;
	}

	/**
	 * 任务截止时间
	 */
	public java.util.Date getEnttime() {
		return enttime;
	}

	/**
	 * 任务截止时间
	 */
	public void setEnttime(java.util.Date value) {
		this.enttime = value;
	}

	/**
	 * 巡查周期
	 */
	public String getCycle() {
		return cycle;
	}

	/**
	 * 巡查周期
	 */
	public void setCycle(String value) {
		this.cycle = value;
	}

	public String getCycleName() {
		return cycleName;
	}

	public void setCycleName(String cycleName) {
		this.cycleName = cycleName;
	}

	/**
	 * 巡查时长
	 */
	public String getDuration() {
		return duration;
	}

	/**
	 * 巡查时长
	 */
	public void setDuration(String value) {
		this.duration = value;
	}

	/**
	 * 巡查里程
	 */
	public String getMileage() {
		return mileage;
	}

	/**
	 * 巡查里程
	 */
	public void setMileage(String value) {
		this.mileage = value;
	}

	/**
	 * 巡查单位
	 */
	public String getUnit() {
		return unit;
	}

	/**
	 * 巡查单位
	 */
	public void setUnit(String value) {
		this.unit = value;
	}

	/**
	 * 巡查单位
	 */
	@Transient
	public String getUnitName() {
		return unitName;
	}

	/**
	 * 巡查单位
	 */
	public void setUnitName(String value) {
		this.unitName = value;
	}

	/**
	 * 巡查人员
	 */
	public String[] getOwer() {
		return this.getStringArray(this.ower);
	}

	/**
	 * 巡查人员
	 */
	public void setOwer(String[] value) {
		this.ower = this.getArrayString(value);
	}

	/**
	 * 巡查人员
	 */
	@Transient
	public String getOwerName() {
		return owerName;
	}

	/**
	 * 巡查人员
	 */
	public void setOwerName(String value) {
		this.owerName = value;
	}

	/**
	 * 任务描述
	 */
	public String getContent() {
		return content;
	}

	/**
	 * 任务描述
	 */
	public void setContent(String value) {
		this.content = value;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	public String getCount() {
		return count;
	}

	public void setCount(String count) {
		this.count = count;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public FileMeta[] getImage() {
		return getFileArray(image);
	}

	public void setImage(FileMeta[] uImages) {
		this.image = getFileString(uImages);
	}

	/**
	 * 设置创建时间值
	 */
	@Override
	public void setCreateTime(java.util.Date time) {
		this.createTime = time;
	}

	public java.util.Date getCreateTime() {
		return this.createTime;
	}

	/**
	 * 设置创建人值
	 */
	@Override
	public void setCreateUserID(String userID) {
		this.createUserid = userID;
	}

	public String getCreateUserID() {
		return this.createUserid;
	}

	/**
	 * 设置创建人值
	 */
	@Override
	public void setCreateUserName(String userName) {
		this.createUsername = userName;
	}

	public String getCreateUserName() {
		return this.createUsername;
	}

	/**
	 * 设置更新时间值
	 */
	@Override
	public void setUpdateTime(java.util.Date time) {
		this.updateTime = time;
	}

	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}

	/**
	 * 设置更新人值
	 */
	@Override
	public void setUpdateUserID(String userID) {
		this.updateUserid = userID;
	}

	public String getUpdateUserID() {
		return this.updateUserid;
	}

	/**
	 * 设置更新人值
	 */
	@Override
	public void setUpdateUserName(String userName) {
		this.updateUsername = userName;
	}

	public String getUpdateUserName() {
		return this.updateUsername;
	}

	public String getNowTime() {
		return nowTime;
	}

	public void setNowTime(String nowTime) {
		this.nowTime = nowTime;
	}

	public String getSecretKey() {
		return secretKey;
	}

	public void setSecretKey(String secretKey) {
		this.secretKey = secretKey;
	}

	public List<String> getHandleList() {
		return handleList;
	}

	public void setHandleList(List<String> handleList) {
		this.handleList = handleList;
	}

	public String getTaskType() {
		return taskType;
	}

	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	public String getTaskTypeName() {
		return taskTypeName;
	}

	public void setTaskTypeName(String taskTypeName) {
		this.taskTypeName = taskTypeName;
	}


	@Override
	protected String getFileString(FileMeta[] items) {
		if (items == null) {
			return null;
		} else {
			return JsonUtils.toJSONString(items);
		}
	}
}
